﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FinScreen.Util;
using SmartQuant.Series;
using SmartQuant.Indicators;
using SmartQuant.Data;
using FinScreen.Model;

namespace FinScreen.Analyzers
{
    [Strategy("T+0", FinScreen.StrategyEnum.All)]
    class Tplus0Strategy : Strategy
    {
        public override IEnumerable<Instrument> Instrument(StrategyContext context)
        {
            return context.MasterBase
               .Where(p => 
                   !p.Name.Contains("ST")
                   && p.Quotes != null
                   && p.Quotes.Count > 2
                   && p.Quotes.ElementAt(p.Quotes.Count() - 1).Close < 20
                   && p.Quotes.ElementAt(p.Quotes.Count() - 1).Open >= p.Quotes.ElementAt(p.Quotes.Count() - 2).High
                   && p.Quotes.ElementAt(p.Quotes.Count() - 1).PctChange > 0
                   && p.Quotes.ElementAt(p.Quotes.Count() - 2).PctChange > 0
                   && p.Quotes.ElementAt(p.Quotes.Count() - 3).PctChange > 0
                   )
               .ToList();
        }

        public override void OnMarket(QuantBox.CSharp2CTPZQ.CThostFtdcDepthMarketDataField data)
        {
        }
    }
}